clear; clc;

inputDir = 'hall_GroundTruth';
outputDir = 'hall_gnd';

file = dir(inputDir);

N = length(file);
for n = 1:N
    fileName = file(n).name;
    if(strfind(fileName, 'bmp'))
        file_n = strcat(inputDir ,'/', fileName);
        img = imread(file_n);
        img = rgb2gray(img);
        
        newName = '';
        for i = 1:length(fileName)
            if(double(fileName(i)) >= double('0') && double(fileName(i)) <= double('9'))
                newName = strcat(newName, fileName(i));
            end
        end
        newName = str2num(newName);
        newName = num2str(newName);
        newName = strcat(newName, '.jpg');
        
        file_n = strcat(outputDir ,'/', newName);
        imwrite(img, file_n);
    end
    fprintf('%d out of %d \n', n, N);
end